import allure

from page_element.roncoo_power_manage import add_pe
from page_object.roncoo_login import RoncooLogin
from page_element.el_A3mall import *
import logging
from utils.timer import sleep



class Add_Menu(RoncooLogin):
    """添加菜单"""

    def page_add_menu_login(self, menuname,menunum,casename,expected):
        # 前置条件：已登录
        self.roncoo_login()
        with allure.step(f"点击权限管理"):
            self.click(add_pe.power_manage)
        with allure.step(f"点击菜单管理"):
            self.click(add_pe.menu_manage)
        with allure.step(f"点击添加"):
            self.click(add_pe.add_btn)
            sleep(2)
        with allure.step(f"输入菜单名称"):
            self.send_keys(add_pe.menu_name,menuname)
            sleep(2)
        with allure.step(f"输入菜单编号"):
            self.send_keys(add_pe.menu_num,menunum)
            sleep(2)
        with allure.step(f"点击保存"):
            self.click(add_pe.save_btn)
            sleep(2)
        with allure.step(f"断言菜单名称"):
            if casename == "正例":
                dy1 = self.text(add_pe.dy1)
                assert expected == dy1
            # else:
            #     dy2 = self.text(add_pe.dy2)
            #     assert expected == dy2